package cloud.seri.auth.service.mapper

import cloud.seri.auth.domain.Menu
import cloud.seri.auth.service.dto.MenuDTO

import org.mapstruct.Mapper
import org.mapstruct.Mapping
import org.mapstruct.Mappings

/**
 * Mapper for the entity [Menu] and its DTO [MenuDTO].
 */
@Mapper(componentModel = "spring", uses = [])
interface MenuMapper : EntityMapper<MenuDTO, Menu> {
    @Mappings(
        Mapping(target = "parent", ignore = true)
    )
    override fun toEntity(dto: MenuDTO): Menu

    fun fromId(id: String?): Menu? {
        if (id == null) {
            return null
        }
        val menu = Menu()
        menu.id = id
        return menu
    }
}
